//Flipterr.txt - A huge, massive rip-off version of door.txt by Jeff Vogel
//
// This script is copmpletely inert until looked at. Then it basically checks to see 
// if a container the script is on is open or closed, and flips it to the opposite. 
// Also, it flashes a print_str to let the player know what just happened. 



// Memory Cells - 
//   0 - Terrain on this space.
//   1 - Is this terrain open or closed? If 1, open, if not, closed.


beginterrainscript; 

variables;
	short i_am_open = 0;
	short cur_terrain;
	
	short door_opened;
	short choice;
body;

beginstate INIT_STATE;
	cur_terrain = (get_memory_cell(0));
	if (get_memory_cell(1) == 1)
	  	i_am_open = 1;
	  	else i_am_open = 0;

break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
	if (i_am_open == 1) {
		print_str_color("You close the coffin.",2);
		flip_terrain(my_loc_x(),my_loc_y());
		i_am_open = 0;
		play_sound(-59);
		end();
		}
		
	if (i_am_open == 0) {
		print_str_color("You open the coffin.",2);
		flip_terrain(my_loc_x(),my_loc_y());
		i_am_open = 1;
		play_sound(-58);
		end();
		}
break;


